<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>selectBank</title>
	
	<style>
		body {
		  padding-top: 3.5rem;
		}
		img {
			width:100px;
			height:100px;
		}
	</style>
	
    <!-- Bootstrap core CSS -->
    <link href="./styles/bootstrap.min.css" rel="stylesheet">
  </head>

  <body>

    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
		  <ol class="breadcrumb">
			<li class="breadcrumb-item"><a href="selectEdition2.html">电子支付:选择接口版本</a></li>
			<li class="breadcrumb-item active" aria-current="page">选择测试行</li>
		  </ol>
        </ul>
        <form class="form-inline my-2 my-lg-0" action="addBank.html">
          <input class="form-control mr-sm-2" type="text" placeholder="银行名称" aria-label="Search">
          <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
		  <button class="btn btn-outline-success my-2 my-sm-0 mx-1" type="submit">Add</button>
        </form>
      </div>
    </nav>

    <main role="main" class="mt-5">
      <div class="container-fluid" style="text-align:center">
        <table class="table table-bordered table-hover">
		  <thead class="thead-dark">
			<tr>
			  <th scope="col">序号</th>
			  <th scope="col">机构名称</th>
			  <th scope="col">银行行号</th>
			  <th scope="col">银行名称</th>
			  <th scope="col">银行联调完成度</th>
			  <th scope="col">联调状态</th>
			  <th scope="col">新增时间</th>
			  <th scope="col">操作</th>
			</tr>
		  </thead>
		  <tbody class="row1">
		  </tbody>
		</table>
        <hr>
      </div> <!-- /container -->
    </main>

    <footer class="container">
      <p>&copy; Company 电子支付</p>
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/javascript" src="js/jquery-slim.min.js"></script>
    <script type="text/javascript" src="js/popper.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/cookie_util.js"></script>
    <script type="text/javascript" src="js/json2.js"></script>
    <script type="text/javascript" src="js/layer/layer.js"></script>
    <script type="text/javascript">
    
	    var bankMsgTemplate = '<tr>'+
								  '<th scope="row">[seq]</th>'+
								  '<td>[departmentName]</td>'+
								  '<td>[bankId]</td>'+
								  '<td>[bankName]</td>'+
								  '<td>[count]/35</td>'+
								  '<td>[progress]</td>'+
								  '<td>[addDate]</td>'+
								  '<td><button class="btn btn-outline-success my-2 my-sm-0" onclick="selectInterface([bankId1],[seq1])">开始联调</button></td>'+
							  '</tr>';
	  	
		var bankList;			  
		$(function(){
			bankList = JSON.parse(localStorage.getItem("bankList"));
			loadBankMsg(bankList);
		});
		
		function loadBankMsg(bankList){
			
			for(var i = 0 ; i < bankList.length ; i++){
				
				var bankId = bankList[i].bankId;
				var bankName = bankList[i].bankName;
				var addDate = bankList[i].addDate;
				var count = bankList[i].count;
		
				var progress;
			
				if(count == '35'){
					progress = "联调完成";
				}else{
					progress = "联调中";
				}
				
				var div = bankMsgTemplate.replace("[departmentName]",localStorage.getItem("departmentName"))
										 .replace("[bankId]",bankId)
										 .replace("[bankName]",bankName)
										 .replace("[count]",count)
										 .replace("[addDate]",addDate)
										 .replace("[progress]",progress)
										 .replace("[seq]",i+1)
										 .replace("[bankId1]",bankId)
										 .replace("[seq1]",i);
				$(".row1").append(div);
		  }
		}
		
		function selectInterface(bankId,i){
			var data = {"bankId":bankId,
						"deptId":localStorage.getItem("departmentId"),
						"version":localStorage.getItem("version")};
			var url = "selectInterface.do";
			$.post(
					url,
					data,
					function(result){
						if(result.state == 0){
							var interfList = result.data;
							localStorage.setItem("interfList", JSON.stringify(interfList));
							localStorage.setItem("bankName", bankList[i].bankName);
							localStorage.setItem("bankId", bankId);
							location.href="selectInterface.html";
						}else{
							alertErr(result.message);
						}
					}
					);
		}
    	
    </script>
  </body>
</html>
